import ajax from '@/utils/request'
import { concatUrl } from '@/utils'

export function getList(data, fields: string | object = { fields: 'id,image' }) {
  return ajax({
    url: concatUrl('/v1/annualCard/annual-card-recommend/index', fields),
    data,
    method: 'GET'
  })
}

// 获取平台年卡
export function getplatformList(data, fields: string | object = { fields: 'id,image' }) {
  return ajax({
    url: concatUrl('/v2/annualCard/annual-card-recommend/index', fields),
    data,
    method: 'GET'
  })
}

export function getDiyListByCarId(data, fields: string | object = { fields: '*' }) {
  return ajax({
    // url: concatUrl('/v1/annualCard/annual-card-category/index', fields),
		// url: concatUrl('/v2/annualCard/annual-card-category/index', fields),
		url: concatUrl('/v1/annualCard/annual-card-category/index-v2', fields),
    data,
    method: 'GET'
  })
}

export function getDiySpecList(data, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/annualCard/annual-card-category/category-goods', fields),
    data,
    method: 'GET'
  })
}

export function getDiySpecUseList(data, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/annualCard/annual-card-category/category-goods-use', fields),
    data,
    method: 'GET'
  })
}

export function getMinConsumption(data = {}, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v2/annualCard/annual-card-category/min-consume', fields),
    data,
    method: 'GET'
  })
}

export function getAnnualCardBalanceList(data = {}, fields: string | object = { fields: '*' }) {
  return ajax({
    // url: concatUrl('/v1/annualCard/annual-card-category/annual-card-list-v2', fields),
		url: concatUrl('/v2/annualCard/annual-card-category/annual-card-list', fields),
    data,
    method: 'GET'
  })
}
/**
 * 获取关联id
 *
 * @param data
 * @param fields
 */
export function getRelatedCouponItem(data) {
  return ajax({
    url: '/v2/annualCard/annual-card-category/related-coupon-item',
    data,
    method: 'POST'
  })
}
/**
 * 预约信息
 * @param data
 * @param fields
 */
export function fetchAnnualCardUse(data = {}, fields: string | object = {}) {
  return ajax({
    url: concatUrl('/v2/order/annual-card-order/coupon-use-v2', fields),
    data,
    method: 'POST'
  })
}
/**
 * 提交预约
 */
export function fetchAnnualCardApply(data = {}, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/order/annual-card-order/apply', fields),
    data,
    method: 'POST'
  })
}

// 电子协议列表
export function getAnnualCardList(data = {}, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/order/annual-card-order/get-list', fields),
    data,
    method: 'GET'
  })
}
export function fetchCouponView(data = {}, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/coupon/coupon-item/view', fields),
    data,
    method: 'GET'
  })
}
